package com.yh.csx.etl;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import com.yh.csx.etl.config.EtlDataSourceManager;
import com.yh.csx.etl.scheduler.EtlSpringScheduler;
import com.yh.csx.etl.scheduler.EtlXxljobScheduler;
import com.yh.csx.etl.worker.EtlWorkerManager;

@Configuration
@Import({ EtlDataSourceManager.class, EtlWorkerManager.class })
public class EtlAutoConfiguration {
    /**
     * 线程默认设置
     */
    public static final int POOL_CORE_SIZE_DEFAULT = Runtime.getRuntime().availableProcessors();
    public static final int POOL_MAX_SIZE_DEFAULT = 100;
    public static final int POOL_QUEUE_CAPACTIRY_DEFAULT = 99999;
    public static final int POOL_KEEPALIVE_SECONDS_DEFALUT = 20;

    @Bean("etlHandler")
    @ConditionalOnProperty(name = "etl.config.scheduler.name", havingValue = "xxljob", matchIfMissing = true)
    public EtlXxljobScheduler getEtlXxljobScheduler() {
        return new EtlXxljobScheduler();
    }

    @ConditionalOnProperty(name = "etl.config.scheduler.name", havingValue = "spring")
    @Bean("etlSpringScheduler")
    public EtlSpringScheduler getEtlSpringScheduler() {
        return new EtlSpringScheduler();
    }
}
